
const util = require('../../utils/util.js')
let globalData = getApp().globalData
Page({
  data: {
    tabs: [{
      name: "全部"
    }, {
      name: "等待处理"
    }, {
      name: "送货中"
    }, {
      name: "订单完成"
    }],
    currentTab: 0,
    pageIndex: 1,
    loadding: false,
    pullUpOn: true,
    orderList:null,
    scrollTop: 0
  },

  onLoad: function(options) {

    var userid= globalData.userInfo.id;
    let postData = { id:userid,status:""};
    console.log(postData)
    util.request("/app/myOrder.html", postData, "GET", false,  false ).then((res) => {
      console.log(res)
      this.setData({
        orderList: res.data,
      })
    
      
     
    }).catch((res) => {
      console.log(res)
      util.toast('请重试');
    })
  },
  change(e) {
  
    
    var userid= globalData.userInfo.id;
    var status=this.data.tabs[e.detail.index].name;
    let postData = { id:userid,status:status};
    console.log(postData)
    util.request("/app/myOrder.html", postData, "GET", false,  false ).then((res) => {
      console.log(res)
      this.setData({
        orderList: res.data,
      })
    
      
     
    }).catch((res) => {
      console.log(res)
      util.toast('请重试');
    })
    this.setData({
      currentTab: e.detail.index
    })
  },
  detail() {
    wx.navigateTo({
      url: '../orderDetail/orderDetail'
    })
  },
  onPullDownRefresh() {
    setTimeout(() => {
      wx.stopPullDownRefresh()
    }, 300);
  },
  onReachBottom() {
    //只是测试效果，逻辑以实际数据为准
    this.setData({
      loadding:true,
      pullUpOn:true
    })
    setTimeout(() => {
      this.setData({
        loadding: false,
        pullUpOn: false
      })
    }, 1000)
  },
  onPageScroll(e) {
    this.setData({
      scrollTop: e.scrollTop
    })
  }
})